<!-- $Id: brand_info.htm 14216 2008-03-10 02:27:21Z testyang $ -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>ECSHOP 管理中心 - 添加角色 </title>
        <meta name="robots" content="noindex, nofollow"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="__CSS__/general.css" rel="stylesheet" type="text/css" />
        <link href="__CSS__/main.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="__ZTREE__/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <style type="text/css">
            ul.ztree{
                margin-top: 10px;
                border: 1px solid #617775;
                background: #f0f6e4;
                width: 220px;
                overflow-y: scroll;
                overflow-x: auto;
            }
        </style>
    </head>
    <body>
        <h1>
            <span class="action-span"><a href="{:U('index')}"> 角色列表</a></span>
            <span class="action-span1"><a href="#">ECSHOP 管理中心</a></span>
            <span id="search_id" class="action-span1"> - 添加角色 </span>
        </h1>
        <div style="clear:both"></div>
        <div class="main-div">
            <form method="post" action="{:U()}" enctype="multipart/form-data" >
                <table cellspacing="1" cellpadding="3" width="100%" class="tree">
                    <tr>
                        <td class="label">角色名称</td>
                        <td>
                            <input type="text" name="name" maxlength="60" value="{$row.name}" />
                            <span class="require-field">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">角色权限</td>
                        <td>
                            <div id="permission_ids">

                            </div>
                            <ul id="permissions" class="ztree"></ul>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">角色描述</td>
                        <td>
                            <textarea  name="intro" cols="60" rows="4"  >{$row.intro}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">排序</td>
                        <td>
                            <input type="text" name="sort" maxlength="40" size="15" value="{$row.sort|default=50}" />
                        </td>
                    </tr>
                    <tr>
                        <td class="label">是否显示</td>
                        <td>
                            <input class="status" type="radio" name="status" value="1" class="status"/> 是
                            <input class="status"  type="radio" name="status" value="0" class="status" /> 否(当角色下还没有商品的时候，首页及分类页的角色区将不会显示该角色。)
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center"><br />
                            <input type="hidden" name="id" value="{$row.id}" />
                            <input type="submit" class="button" value=" 确定 " />
                            <input type="reset" class="button" value=" 重置 " />
                        </td>
                    </tr>
                </table>
            </form>
        </div>

        <div id="footer">
            共执行 1 个查询，用时 0.018952 秒，Gzip 已禁用，内存占用 2.197 MB<br />
            版权所有 &copy; 2005-2012 上海商派网络科技有限公司，并保留所有权利。
        </div>
    <js href='__JS__/jquery.min.js'/>
    <script type="text/javascript" src="__ZTREE__/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__ZTREE__/js/jquery.ztree.excheck.min.js"></script>

    <script type='text/javascript'>
        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    pIdKey: 'parent_id',
                },

            },
            check:{
                enable:true,
                chkboxType:{"Y":"s","N":"s"},
            },
            callback:{
                onCheck:function(){
                    //获取所有选中节点
                var nodes = permission_ztree.getCheckedNodes(true);
                    $("#permission_ids").empty();
                    $(nodes).each(function(i,v){
                        var html="<input type='hidden' name='permission_id[]' value='"+ v.id+"'/>";
                        $(html).appendTo($("#permission_ids"));
                    });
                },
            },
        };

        var permissions = {$permissions};

        //初始化ztree插件
        var permission_ztree = $.fn.zTree.init($("#permissions"), setting, permissions);
        //展开所有的节点
        permission_ztree.expandAll(true);

        //权限的回显示
        <present name="row">
            // 获取角色对应的权限id
            var permission_ids={$row.permission_ids};
            $(permission_ids).each(function(i,v){
                var node=permission_ztree.getNodeByParam('id',v);
                //console.debug(node);
                permission_ztree.checkNode(node,true);
                var html="<input type='hidden' name='permission_id[]' value='"+ v +"'/>";
                $(html).appendTo($("#permission_ids"));
            });
        </present>

        $('.status').val([{$row['status']|default=1}]);
    </script>
    </body>
</html>